package com.crossdomain.www.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.crossdomain.common.ControllerResponseBody;
import com.crossdomain.www.controller.domain.User;
import com.crossdomain.www.controller.domain.UserMessage;

@Controller
@RequestMapping("/user/")
public class TestCrossController {
    @RequestMapping("/findUserMessageNoLogin.action")
    public @ResponseBody ControllerResponseBody<UserMessage> findUserMessageNoLogin(@RequestBody String json) {
        ControllerResponseBody<UserMessage> controllerResponseBody =new ControllerResponseBody<UserMessage>();        
        UserMessage userMessage =new UserMessage();
        userMessage.setContent("消息内容");
        userMessage.setId(1231213L);
        userMessage.setReadStatus(true);
        userMessage.setTitle("消息标题");
        userMessage.setUserId(1L);
        controllerResponseBody.setData(userMessage);
        return controllerResponseBody;
    }
    
    @RequestMapping("/findUserMessageNeedLogin.action")
    public @ResponseBody ControllerResponseBody<UserMessage> findUserMessageNeedLogin(@RequestBody String json) {
        ControllerResponseBody<UserMessage> controllerResponseBody =new ControllerResponseBody<UserMessage>();        
        UserMessage userMessage =new UserMessage();
        userMessage.setContent("消息内容");
        userMessage.setId(1231213L);
        userMessage.setReadStatus(true);
        userMessage.setTitle("消息标题");
        userMessage.setUserId(1L);
        controllerResponseBody.setData(userMessage);
        return controllerResponseBody;
    }
    
    @RequestMapping("/mockLogin.action")
    public @ResponseBody ControllerResponseBody<String>  mockLogin(HttpSession session) {
        User user =new User();
        user.setId("1");
        user.setName("jannal");
        user.setPassword("afsfasdfasdf");
        session.setAttribute("user", user);
        ControllerResponseBody<String> controllerResponseBody =new ControllerResponseBody<String>();  
        controllerResponseBody.setData("登录成功");
        return controllerResponseBody;
    }
}
